import { ChatSourceDocumentTypeEnum } from "@src/component/business/BizChatPanel/chat/model"
import { ChatBusinessSourceDocumentType } from "@src/component/business/BizChatPanel/chat/types"
import { SettingGPTConfigType, SettingGPTPromptWordItem, SettingGPTRobotModuleConfigType } from "@src/modules/setting/gpt/types"

type GetChatHistoryMessageModel = {
  // 会话ID
  conversationId: string;
  pageNum: number;
  pageSize: number;
}

type SendChatConversationContentModel = {
  sender: string;
  content: string;
  contentType: string;
  type: string;
  conversationId: string;
}

type SendChatConversationContentShareModel = {
  tenantId?: string;
  loginUserId?: string;
  share?: number;
} & SendChatConversationContentModel

type DeleteChatConversationContentModel = {
  conversationId: string;
  conversationContentId: string;
}

type GenerateSimilarQuestionsModel = {
  question: string;
  tenantId?: string;
}

type AddQuestionToStandardLibModel = {
  id: string;
  question: string;
  answer: string;
  similarQuestions: string[];
}

type InsertStandardQuestionModel = {
  question: string;
  answer: string;
  similarQuestions: string[];
}

type UpdateStandardQuestionModel = {
  id: string;
  question: string;
  answer: string;
  similarQuestions: string[];
}

type QueryQuestionInStandardLibModel = {
  question: string;
}

type QueryQuestionInStandardLibShareModel = QueryQuestionInStandardLibModel & {
  tenantId?: string;
}

type GetChatLikeMessageModel = {
  /**
   * 当前会话消息 id
   */
  conversationContentId: string;
  /**
   * 会话问题
  */
  question: string;
  /**
    * 会话答案
  */
  answer: string;
  /** 
   * 会话来源文章
  */
  sourceDocumentList: string;
  /** 
   * 会话来源类型
  */
  sourceDocumentType: ChatSourceDocumentTypeEnum;
  /** 
   * 机器人 id
  */
  robotId: string;
  /**
   * 机器人应用 id
   */
  robotAppId: string;
}

type GetChatLikeMessageShareModel = {
  tenantId?: string;
  loginUserId?: string;
} & GetChatLikeMessageModel

type GetChatDisLikeMessageModel = {
  /**
   * 当前会话消息 id
   */
  conversationContentId?: string;
  /**
    * 会话问题
   */
  question: string;
  /**
     * 会话答案
   */
  answer: string;
  /** 
   * 会话来源文章
  */
  sourceDocumentList: string;
  /** 
   * 会话来源类型
  */
  sourceDocumentType: ChatSourceDocumentTypeEnum;
  /** 
   * 机器人 id
  */
  robotId: string;
  /**
   * 机器人应用 id
   */
  robotAppId: string;
}

type GetChatDisLikeMessageShareModel = {
  tenantId?: string;
  loginUserId?: string;
} & GetChatDisLikeMessageModel

type GetChatContentSecurityModel = {
  content: string;
}

type GetChatSummaryFieldsModel = {
  formType: string;
  fieldName: string;
  displayName: string;
}

type ChatSummaryModel = {
  fields: Array<GetChatSummaryFieldsModel>;
  tasks: Array<{[key: string]: string}>
}

type GetTextToReportsModel = {
  dataOrigin?: string;
  text: string;
}

type GetBaoGPTSettingModel = {

}

type UpdateBaoGPTSettingModel = Partial<SettingGPTConfigType>

type GetBaoGPTQuestionListModel = {
  pageNum: number;
  pageSize: number;
  type?: number;
  typeList?: number[];
  keyword?: string;
}

type GetBaoGPTLogListModel = {
  pageNum: number;
  pageSize: number;
  keyword?: string;
}

type DeleteBaoGPTQuestionModel = {
  ids: string[];
}

type GetBaoGPTQuestionModel = {
  id: string;
}

type ChatBaseParams = {
  tenantId: string
  userId: string
  businessId?: string
  conversationId: string
  type: number
  modelName?: string
  vectorStoreType?: string
  embeddingType?: string
  stream?: boolean
  isAllowUseCommonModel?: boolean
  robotId: string
  appId: string
  imMessageId?: string
}

type ChatInitParams = ChatBaseParams

type ChatConversationParams = ChatBaseParams & {
  messages: any[]
}

type GetChatConversationModel = {
  client: 0;
  robotId: string;
  type: string;
}

type GetChatConversationShareModel = {
  tenantId?: string;
  loginUserId?: string;
  share?: number;
} & GetChatConversationModel

type DeleteChatRobotModel = {
  id: string | number;
}

type CreateChatRobotModel = {
  name: string;
}

type UpdateChatRobotNameModel = {
  id: string | number;
  name: string;
}

type ToggleChatRobotModel = {
  id: string | number;
  enable: number;
}

type GetGPTRobotModel = {
  id: string | number;
}

type GetGPTRobotAppModel = {
  robotId: string | number;
  id: string | number;
}

type UpdateBIRobotModel = {
  title: string;
  content: string;
}

type GetAddGPTRobotAppModel = {
  robotId: string | number;
  type: string;
}

type DeleteGPTRobotAppServiceModel = {
  id: string | number;
  robotId: string | number;
}

type GetRobotLogCountListModel = {
  robotId: string | number;
}

type GetGPTRobotAppListModel = {
  robotId: string | number;
  tenantId?: string;
}

type GetGPTRobotOutsideModulesModel = {

}

type UpdateRobotSettingModel = {
  id: string | number;
  setting: string;
  name: string;
}

type UpdateRobotAppSettingModel = {
  id: string | number;
  setting: string;
}

type UpdateRobotAppIntelligentQASettingModel = {
  robotId: string | number;
  robotAppId: string | number;
  insideModuleConfig: SettingGPTRobotModuleConfigType;
  outsideModuleConfig: SettingGPTRobotModuleConfigType;
}

type UpdateRobotBiSettingModel = {
  robotId: string | number;
  robotAppId: string | number;
  promptWordList: Array<UpdateBIRobotModel>
}

type UpdateIntelligentQAPromptWordModel = {
  robotId: string | number;
  robotAppId: string | number;
  promptWordList: SettingGPTPromptWordItem[];
}

type UpdateTranslateModel = {
  robotId: string | number;
  robotAppId: string | number;
  translateToLanguage: string;
}

type UpdateRobotSettingModelNameModel = {
  id: string | number;
  modelName: string;
}

type UpdateRobotSettingReleaseChannelModel = {
  id: string | number;
  releaseChannel: string | number;
}

type CheckRepeatRobotSettingReleaseChannelModel = {
  id: string | number;
  releaseChannel: string | number;
}

type UpdateOpenDDAssistantModel = {
  id: string | number;
  openDDAssistant: boolean;
}

type AddDingtalkAssistantDocModel = {
  assistantId: string;
  docUrl: string;
  authCode: string;
}

type DeleteDingtalkAssistantDocModel = {
  authCode: string;
}

type DingtalkAssistantDocStudyModel = {
  assistantId: string;
  authCode: string;
}

type AddDingtalkAssistantModel = {
  assistantId: string;
  authCode: string;
}

type UpdateRobotSettingShareModel = {
  id: string | number;
  share: boolean;
}

type RobotAppRangeInsertModel = {
  robotAppId: string | number;
  rangeForm: {
    tagIds: string[];
    roleIds: string[];
    serviceProviderIds: string[];
    userIds: string[];
  }
}

type RobotAppWikiTypeInsertModel = {
  robotAppId: string | number;
  wikiTypeIdList: string[];
}

type RobotAppWikiTypeQueryModel = {
  robotAppId: string | number;
}

type RobotQueryIMRobotIdModel = {

}

export {
  GetChatHistoryMessageModel,
  SendChatConversationContentModel,
  GetChatLikeMessageModel,
  GetChatDisLikeMessageModel,
  GetChatContentSecurityModel,
  GetBaoGPTSettingModel,
  UpdateBaoGPTSettingModel,
  GetBaoGPTQuestionListModel,
  DeleteBaoGPTQuestionModel,
  ChatBaseParams,
  ChatConversationParams,
  ChatInitParams,
  GetChatConversationModel,
  DeleteChatConversationContentModel,
  GetBaoGPTLogListModel,
  DeleteChatRobotModel,
  ToggleChatRobotModel,
  GetGPTRobotModel,
  GetGPTRobotOutsideModulesModel,
  UpdateRobotSettingModel,
  CreateChatRobotModel,
  UpdateChatRobotNameModel,
  GetChatConversationShareModel,
  SendChatConversationContentShareModel,
  GetChatLikeMessageShareModel,
  GetChatDisLikeMessageShareModel,
  GenerateSimilarQuestionsModel,
  AddQuestionToStandardLibModel,
  UpdateRobotSettingModelNameModel,
  UpdateRobotSettingShareModel,
  GetAddGPTRobotAppModel,
  GetGPTRobotAppListModel,
  DeleteGPTRobotAppServiceModel,
  GetRobotLogCountListModel,
  GetGPTRobotAppModel,
  UpdateRobotAppSettingModel,
  UpdateRobotAppIntelligentQASettingModel,
  UpdateIntelligentQAPromptWordModel,
  UpdateBIRobotModel,
  UpdateRobotBiSettingModel,
  ChatSummaryModel,
  InsertStandardQuestionModel,
  UpdateStandardQuestionModel,
  QueryQuestionInStandardLibModel,
  QueryQuestionInStandardLibShareModel,
  GetTextToReportsModel,
  GetBaoGPTQuestionModel,
  UpdateTranslateModel,
  RobotAppRangeInsertModel,
  RobotAppWikiTypeInsertModel,
  RobotAppWikiTypeQueryModel,
  UpdateRobotSettingReleaseChannelModel,
  CheckRepeatRobotSettingReleaseChannelModel,
  RobotQueryIMRobotIdModel,
  UpdateOpenDDAssistantModel,
  AddDingtalkAssistantDocModel,
  AddDingtalkAssistantModel,
  DingtalkAssistantDocStudyModel,
  DeleteDingtalkAssistantDocModel
}
